{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "# 马赛克效果基本原理：用区域内的某像素的颜色代替整个区域的颜色\n",
    "img = cv2.imread('image0.jpg',1)\n",
    "imgInfo = img.shape\n",
    "height = imgInfo[0]\n",
    "width = imgInfo[1]\n",
    "# 指定马赛克的整个区域\n",
    "for m in range(100,300):\n",
    "    for n in range(100,200):\n",
    "        # 选定某个像素然后对区域进行替代，指定10*10中的100个像素点为一个马赛克小区域\n",
    "        # 宽高每隔10个像素点取一个像素进行替代\n",
    "        if m%10==0 and n%10==0:\n",
    "            # 选定像素进行区域填充\n",
    "            for i in range(0,10):\n",
    "                for j in range(0,10):\n",
    "#                     (b,g,r) = img[m,n]\n",
    "#                     img[i+m,j+n] = (b,g,r)\n",
    "                      img[i+m,j+n] = img[m,n]\n",
    "cv2.imshow('dst',img)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
